package edu.mit.compilers.assembly.x64.codes;

import edu.mit.compilers.assembly.x64.basic.X64Operand;

public class X64JumpCode extends X64Code {
    public enum Type {
        EQ,
        NE,
        NONE
    }

    private final X64Operand where;
    private final Type type;

    public X64JumpCode(X64Operand where, Type type) {
        this.where = where;
        this.type = type;
    }

    private String typeToInstruction(Type type) {
        switch (type) {
            case EQ:    return "je";
            case NE:    return "jne";
            case NONE:  return "jmp";
            default:
                assert false;
                return null;
        }
    }

    @Override
    protected String getStringFroShow(String prefix, boolean debug) {
        return prefix + typeToInstruction(type) + TAB + where.getAddress() + '\n';
    }
}
